home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # IEEE1394-specific hotplug policy agent.
- #
- # This should handle 2.4.10 (or later) IEEE1394 hotplugging, with a
- # consistent framework for adding device and driver specific treatments.
- #
- # Kernel IEEE1394 params are:
- #
- # ACTION=add or remove
- # VENDOR_ID=24 bit vendor id
- # GUID=64 bit globally unique id
- # SPEFICIER_ID=24 bit id of owner of specification
- # VERSION=version of specification
- #
- # See IEEE1212 for details on these parameters.
- #
- # HISTORY:
- # 26-Mar-2002 Small cleanups to match other .agent files. (gkh)
- # 16-Sept-2001 Initial version from Kristian Hogsberg
- # <hogsberg@users.sourceforge.net> (plus tweaks)
- #
- # $Id: ieee1394.agent,v 1.13 2004/09/20 21:43:37 kroah Exp $
- #
-
- cd /etc/hotplug
- . ./hotplug.functions
- # DEBUG=yes export DEBUG
-
- # generated by modutils 2.4.9 or later, for 2.4.10 and later kernels
- MAP_CURRENT=$MODULE_DIR/modules.ieee1394map
-
- # accumulates list of modules we may care about
- DRIVERS=
-
- if [ "$ACTION" = "" ]; then
- mesg Bad IEEE1394 agent invocation
- exit 1
- fi
-
-
- device_vendor_id=$((0x$VENDOR_ID))
- device_specifier_id=$((0x$SPECIFIER_ID))
- device_version=$((0x$VERSION))
-
- MATCH_VENDOR_ID=0x0001
- MATCH_SPECIFIER_ID=0x0004
- MATCH_VERSION=0x0008
-
- #
- # stdin is "modules.ieee1394map" syntax
- # on return, all matching modules were added to $DRIVERS
- #
- ieee1394_map_modules ()
- {
- # comment line lists (current) pci_device_id field names
- read ignored
-
- while read module match_flags vendor_id model_id specifier_id version
- do
- : check match for $module
-
- # convert from hex to dec
- match_flags=$(($match_flags))
- vendor_id=$(($vendor_id)); model_id=$(($model_id))
- specifier_id=$(($specifier_id)); version=$(($version))
-
- : vendor_id $vendor_id $device_vendor_id
- if [ $(($match_flags & $MATCH_VENDOR_ID)) -ne 0 ] && [ $vendor_id -ne $device_vendor_id ]; then
- continue
- fi
-
- : specifier_id $specifier_id $device_specifier_id
- if [ $(($match_flags & $MATCH_SPECIFIER_ID)) -ne 0 ] && [ $specifier_id -ne $device_specifier_id ]; then
- continue
- fi
-
- : version $version $device_version
- if [ $(($match_flags & $MATCH_VERSION)) -ne 0 ] && [ $version != $device_version ]; then
- continue
- fi
-
- DRIVERS="$module $DRIVERS"
- done
- }
-
- #
- # What to do with this IEEE1394 hotplug event?
- #
- case "$ACTION" in
-
- add)
- LABEL="IEEE1394 product 0x$VENDOR_ID/0x$SPECIFIER_ID/0x$VERSION"
-
- # on 2.4 systems, modutils maintains MAP_CURRENT
- if [ -r $MAP_CURRENT ]; then
- load_drivers ieee1394 $MAP_CURRENT "$LABEL"
- fi
-
- if [ "$DRIVERS" = "" ]; then
- mesg "... no drivers for $LABEL"
- exit 2
- fi
- ;;
-
- remove)
- ieee1394_map_modules < $MAP_CURRENT
- for MODULE in $DRIVERS
- do
- if [ -x $HOTPLUG_DIR/ieee1394/$MODULE ]; then
- $HOTPLUG_DIR/ieee1394/$MODULE
- fi
- done
- ;;
-
- *)
- debug_mesg "IEEE1394 '$ACTION' event not supported"
- exit 1
- ;;
-
- esac
-